<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/templates/template.xhtml"	
	xmlns:p="http://primefaces.prime.com.tr/ui">

	<ui:define name="conteudo">
		<br />
		<div align="center">
		<h:form id="cadastraFaseForm">
			<p:panel>
				<h:messages infoClass="mensagem_formulario_success" errorClass="mensagem_formulario_error"  globalOnly="true"/>
				<f:facet name="header">
					<h:outputText value="#{msg.faseTitulo}"></h:outputText>
				</f:facet>
				<h:panelGroup>
					<fieldset id="legend_area"><legend id="legend">
					<h:outputLabel value="#{msg.faseDados}" /></legend>
					<div style="text-align: left">
					<h:outputLabel
						value="#{msg.nome}" for="nomeFase" styleClass="label_80" />
					<h:inputHidden value="#{cadastraFase.fase.id}" />
					<h:inputHidden value="#{cadastraFase.fase.codigo}" /> 
					<h:inputText id="nomeFase" value="#{cadastraFase.fase.nome}"
						styleClass="caixa_80" maxlength="40" required="true" requiredMessage="#{msg.nomeVazio}" >
						<rich:ajaxValidator event="onblur" />
					</h:inputText> <rich:message for="nomeFase" styleClass="mensagem_erro_campo" /><br />
					<h:outputLabel value="#{msg.descricao}" for="descricaoFase"
						styleClass="label_80" /> <h:inputTextarea id="descricaoFase"
						value="#{cadastraFase.fase.descricao}" cols="100" rows="4"
						styleClass="caixa_80" required="true" requiredMessage="#{msg.descricaoVazio}" 
						onkeyup="this.value = this.value.substring(0, 150);">
						<rich:ajaxValidator event="onblur" />
					</h:inputTextarea> <rich:message for="descricaoFase" styleClass="mensagem_erro_campo" /></div>
					<a4j:commandButton value="#{msg.botaoSalvar}"
						action="#{cadastraFase.save}"
						reRender="cadastraFaseForm, faseList" /> <a4j:commandButton
						value="#{msg.botaoAtualizar}" action="#{cadastraFase.atualiza}"
						reRender="cadastraFaseForm, faseList, mensagens" /></fieldset>
				</h:panelGroup>
			</p:panel>
		</h:form><br />
		<h:form>
			<p:panel>
				<h:panelGroup>
					<fieldset id="legend_area" style="height: 280px">
					<legend id="legend"> <h:outputLabel value="#{msg.faseListagem}" /></legend>
					<a4j:outputPanel id="faseList">
						<div style="height: 30px;"><rich:datascroller id="ds"
							for="faseListData" maxPages="3" renderIfSinglePage="false"/></div>
						<br />
						<rich:dataTable onRowMouseOver="this.style.backgroundColor='#fff1df'"
						onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" 
						value="#{cadastraFase.faseList}" binding="#{cadastraFase.objDataTableFase}" var="fase"
							id="faseListData" rowKeyVar="row" rows="5" reRender="ds"
							style="width: 100%">
							<rich:column sortBy="#{fase.codigo}" filterBy="#{fase.codigo}"
								filterEvent="onkeyup" width="10px">
								<f:facet name="header"><h:outputLabel value="#{msg.codigo}" /></f:facet>
								<h:outputText value="#{fase.codigo}" />
							</rich:column>
							<rich:column sortBy="#{fase.nome}" filterBy="#{fase.nome}"
								filterEvent="onkeyup" width="70">
								<f:facet name="header"><h:outputLabel value="#{msg.nome}" /></f:facet>
								<h:outputText value="#{fase.nome}" />
							</rich:column>
							<rich:column sortBy="#{fase.descricao}" filterBy="#{fase.descricao}" 
								filterEvent="onkeyup">
								<f:facet name="header"><h:outputLabel value="#{msg.descricao}" /></f:facet>
								<h:outputText value="#{fase.descricao}" />
							</rich:column>
							<rich:column width="35px">
								<f:facet name="header"></f:facet>
								<a4j:commandButton image="/images/excluir.jpg" action="#{cadastraFase.remove}" reRender="faseList"/>
								<a4j:commandLink styleClass="imagem_alterar" action="#"	reRender="cadastraFaseForm">
									<f:setPropertyActionListener target="#{cadastraFase.fase}"
										value="#{fase}" />
								</a4j:commandLink>
							</rich:column>
						</rich:dataTable>
					</a4j:outputPanel></fieldset>
				</h:panelGroup>
			</p:panel>
		</h:form><br />
		</div>
	</ui:define>
</ui:composition>